package cn.demoncat.util.io.entity;

import java.io.IOException;

import javax.servlet.ServletOutputStream;
import javax.servlet.WriteListener;

/**
 * 弱化版ServletOutputStream
 * 
 * 1、包装实际的Response.out
 * 
 * 2、隐藏close方法，始终由Tomcat容器自动关闭，以避免异常情况
 * 
 * @author 延晓磊
 *
 * @since 2020年6月6日
 */
public class WeakServletOutputStream extends ServletOutputStream{

	private final ServletOutputStream out;

	public WeakServletOutputStream(ServletOutputStream out) {
		super();
		this.out = out;
	}
	
	@Override
	public void close() throws IOException {
		// 始终由Tomcat容器自动关闭，以避免异常情况
	}

	@Override
	public void print(String s) throws IOException {
		out.print(s);
	}

	@Override
	public void print(boolean b) throws IOException {
		out.print(b);
	}

	@Override
	public void print(char c) throws IOException {
		out.print(c);
	}

	@Override
	public void print(int i) throws IOException {
		out.print(i);
	}

	@Override
	public void print(long l) throws IOException {
		out.print(l);
	}

	@Override
	public void print(float f) throws IOException {
		out.print(f);
	}

	@Override
	public void print(double d) throws IOException {
		out.print(d);
	}

	@Override
	public void println() throws IOException {
		out.println();
	}

	@Override
	public void println(String s) throws IOException {
		out.println(s);
	}

	@Override
	public void println(boolean b) throws IOException {
		out.println(b);
	}

	@Override
	public void println(char c) throws IOException {
		out.println(c);
	}

	@Override
	public void println(int i) throws IOException {
		out.println(i);
	}

	@Override
	public void println(long l) throws IOException {
		out.println(l);
	}

	@Override
	public void println(float f) throws IOException {
		out.println(f);
	}

	@Override
	public void println(double d) throws IOException {
		out.println(d);
	}

	@Override
	public boolean isReady() {
		return out.isReady();
	}

	@Override
	public void setWriteListener(WriteListener writeListener) {
		out.setWriteListener(writeListener);
	}

	@Override
	public void write(int b) throws IOException {
		out.write(b);
	}

	@Override
	public void write(byte[] b) throws IOException {
		out.write(b);
	}

	@Override
	public void write(byte[] b, int off, int len) throws IOException {
		out.write(b, off, len);
	}

	@Override
	public void flush() throws IOException {
		out.flush();
	}

	

}
